#!/bin/bash
test_lmbench(){
	if [ -d "$install_unixbench_dir" ];then
		# 设置所有CPU为性能模式
		cpupower -c all frequency-set -g performance

		# 切换工作目录
		pushd ${install_unixbench_dir}/results
		
		rm -rf `ls grep -vi Makefile`
		pushd ${install_unixbench_dir}

		make clean
		chek_status "$?" '执行[ make clean]'

		make results
		chek_status "$?" '执行[ make results]'
		make see | tee -a lmbench.log
		for((i=2;i<=3;i++));do
			red_z_green_z "如需终止请执行--------->" "[ sudo kill -9 $$ ]"
			make rerun
			make see | tee -a lmbench.log
			chek "第${i}次测试"
		done	
		red_z_green_z "测试结果已保存至: " "`pwd`/results/目录下" 
		red_z_green_z "保存文件: " "summary.out文件"
	else
		red_bg "路径不存在: [ $install_unixbench_dir ]"
	fi
}
if [[ "$1" == 'f' ]];then
    if [[ -e './item.sh' ]];then
        source ./item.sh
    else
        echo -e "请进入目录:[ spzx/ ]再执行脚本"
        exit 1
    fi
    test_lmbench
else
    if [[ -z "$1" ]];then
        echo -e "请在脚本执行的后面加上一个参数直接进行测试，例如：
bash spzx/test/lmbench-3.0-a9.sh.sh f"
    fi
fi